package com.example.springboot02amqp.controller;

import com.example.springboot02amqp.model.db.Study;
import com.example.springboot02amqp.service.IStudyService;
import com.example.springboot02amqp.vo.BaseResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Future;

/**
 * Created with IntelliJ IDEA.
 * User: 喵喵~
 * Date: 2022/4/3
 * Time: 23:20
 * Description:
 */
@RestController
public class StudyController {
    @Autowired
    IStudyService studyService;
    @GetMapping("/get/{id}")
    public Study getById(@PathVariable Integer id){
        return studyService.getById(id);
    }

    @GetMapping("/get/name")
    public String getByName(@RequestParam String name){
        return studyService.getByName(name);
    }

    @GetMapping("/test1")
    public String test1(){
       studyService.asyncTask();
       return "ok";
    }

    @GetMapping("/test2")
    public Future<BaseResultVO<String>> asyncTask(@RequestParam String s){
        return studyService.asyncTask(s);
    }
}
